package com.learning.security.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.learning.security.dal.dataobject.AdminRoleRightDO;
import com.learning.security.dal.mysql.AdminRoleRightMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 角色和权限点关联表 服务实现类
 * </p>
 *
 * @author xxx
 * @since 2024-10-04
 */
@Service
public class AdminRoleRightServiceImpl extends ServiceImpl<AdminRoleRightMapper, AdminRoleRightDO> implements AdminRoleRightService {
    @Autowired
    private AdminRoleRightMapper adminRoleRightMapper;

    @Override
    public boolean assignRight(Long roleId, Long rightId) {

        return Db.save(new AdminRoleRightDO().setRoleId(roleId).setRightId(rightId));
    }

    @Override
    public List<AdminRoleRightDO> getRoleRightByRightId(Long rightId) {

        return adminRoleRightMapper.getRoleRightByRightId(rightId);
    }
}
